snapshot: Only create clip nodes if we need to
authorTimm Bäder <mail@baedert.org>
Fri, 1 Dec 2017 06:38:43 +0000 (07:38 +0100)
committerTimm Bäder <mail@baedert.org>
Fri, 1 Dec 2017 06:38:43 +0000 (07:38 +0100)
Clip nodes have a clip rect and we only need to actually create a clip
node if any child node gets clipped at all. If the clip rect conains the
child node bounds entirely, we don't need a clip node.

gtk/gtksnapshot.c

index 4995c3dc8c6e0b4081fe72490dcec988ddbf3c5f..c969fdece63f21781d9aa3de0bb8903dedd7c6b4 100644 (file)
@@ -548,6 +548,10 @@ gtk_snapshot_collect_clip (GtkSnapshot      *snapshot,
   if (node == NULL)
     return NULL;
 
+  /* Check if the child node will even be clipped */
+  if (graphene_rect_contains_rect (&state->data.clip.bounds, &node->bounds))
+    return node;
+
   /* Its not uncommon to produce stacked clip nodes, which are trivial
      to merge, so do that here */
   if (gsk_render_node_get_node_type (node) == GSK_CLIP_NODE)